home *** CD-ROM | disk | FTP | other *** search
- /*
- File: AdvancedRuler.h
-
- Contains: xxx put contents here xxx
-
- Written by: Essam Zaky
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 1/4/94 EZ clean up
- <1> 1/4/94 EZ first checked in
-
- */
-
- #ifndef _AdvancedRuler_
- #define _AdvancedRuler_
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _RulerObject_
- #include "RulerObject.h"
- #endif
-
- //***************************************************************************************************
-
- const ClassId kAdvancedRulerClassId = 'rulr';
-
- const AttrId kIndentAttr = 'ndnt';
- const AttrId kLeftMarginAttr = 'lMrg';
- const AttrId kRightMarginAttr = 'rMrg';
- const AttrId kLineSpacingAttr = 'lspc';
-
-
- const kMaxTabCount = 20;
-
-
- //***************************************************************************************************
-
- typedef Ttab TtabTable[kMaxTabCount];
- //***************************************************************************************************
-
- //constants for TLineSpacing.spacingUnit
- const ushort kFixedPixelsUnit = 0;
- const ushort kLinesUnit = 1;
-
- class CLineSpacing : private SingleObject {
- public:
- CLineSpacing() {}
-
- Boolean IsEqual(CLineSpacing aSpacing) const;
-
- void GetParams(short* unit, short* value, Boolean* halfLine) const;
-
- void SetParams(short newUnit, short newVal, Boolean halfLine = false);
-
- inline void SetUnit(short newUnit) {fUnit = ushort(newUnit);}
- inline void IncrementValue() {++fValue;} //increment lines by 1/2
- inline void DecrementValue() {--fValue;} //derement lines by 1/2
-
- void AdjustLineHite(TLineHiteInfo* lineHiteInfo) const;
-
- private:
- ushort fUnit : 1;
- ushort fValue : 15; //if fUnit is kLinesUnit ==> bit 0 is 1 ==> half line
- };
- typedef CLineSpacing* CLineSpacingPtr;
-
- //***************************************************************************************************
-
-
- //•CTabs should not allocate in any of its member fns, since it may be a record in a Handle object
-
- class CTabs : private SingleObject {
- public:
- CTabs() {fCount = 0;}
-
- inline short GetCountTabs() const {return fCount;}
- void GetTabsTable(TtabTable theTable) const;
-
- Ttab GetTab(short tabIndex) const;
-
- void InsertTab(Ttab theTab);
- void RemoveTab(short tabIndex);
-
- Boolean SearchTab(short width, short* index) const; //caller should pass "width" scaled properly
- short SearchNearestTab(short width) const;
-
- Fixed CalcPendingTabWidth(const TPendingTab* pendingTab, Fixed tabTrailWidth
- , Fixed remainingWidth) const;
-
- #ifdef txtnScal
- Fixed GetTabWidth(Fixed tabPixStart, TPendingTab* pendingTab, short numer =1, short denom=1) const;
- #else
- Fixed GetTabWidth(Fixed tabPixStart, TPendingTab* pendingTab) const;
- #endif
-
- Boolean IsEqual(const CTabs* tabsToCheck) const;
-
- private:
- char fCount;
- TtabTable fTable;
-
- #ifdef txtnScal
- Ttab Width2Tab(Fixed width, short numer, short denom,) const;
- #else
- Ttab Width2Tab(Fixed width) const;
- #endif
- };
- //***************************************************************************************************
-
-
-
- class CAdvancedRuler : public CBasicRuler {
- public:
- CAdvancedRuler();
-
- inline void IAdvancedRuler() {this->IBasicRuler();}
-
- //•override
- virtual ClassId GetClassId() const;
-
- virtual void GetAttrIDs(short* countAttr, AttrId* attrArray) const;
-
- virtual CAttrObject* CreateNew() const;
-
- virtual void SetDefaults(long message = 0);
-
- #ifdef txtnScal
- virtual Fixed GetEffectiveLineWidth(Fixed width, Boolean paragStart, short numer=1, short denom =1) const;
- virtual Fixed GetLineLeftEdge(char direction, Boolean paragStart, short numer=1, short denom =1) const;
- virtual Fixed GetTabWidth(Fixed tabPixStart, TPendingTab* pendingTab, short numer =1
- , short denom=1) const;
- #else
- virtual Fixed GetEffectiveLineWidth(Fixed width, Boolean paragStart) const;
- virtual Fixed GetLineLeftEdge(char direction, Boolean paragStart) const;
- virtual Fixed GetTabWidth(Fixed tabPixStart, TPendingTab* pendingTab) const;
- #endif
-
- virtual void AdjustLineHite(TLineHiteInfo* lineHiteInfo) const;
- virtual Fixed CalcPendingTabWidth(const TPendingTab* pendingTab, Fixed tabTrailWidth
- , Fixed remainingWidth) const;
-
-
- //input/output methods
- virtual OSErr WriteToStream(CStream* outputStream);
- virtual OSErr ReadFromStream(CStream* inputStream);
-
- protected:
- //•override
- virtual long GetAttrFlags(AttrId theAttr, const void* attrBuffer, long updateMessage =0) const;
-
- virtual Boolean EqualAttribute(AttrId theAttr, const void* valToCheck) const;
-
- virtual void AttributeToBuffer(AttrId theAttr, void* attrBuffer) const;
-
- virtual void BufferToAttribute(AttrId theAttr, const void* attrBuffer);
-
- virtual void UpdateAttribute(AttrId theAttr, const void* srcAttr, long updateMessage
- , const void* continuousAttr = nil);
- /*if updateMessage == kRemoveTab ==> srcAttr is a ptr to the tabValue(short), note that tabValue is chosen instead of the
- tabIndex since UpdateAttribute is normally called for a selection of rulers, and the tabValue is what identify
- a tab over different rulers.
- kInsertTab ==> srcAttr is a ptr to the tab to be inserted
- if updateMessage is 0 ==> srcAttr is a ptr to a CTabs object and *srcAttr will become the new tabs
- */
-
- private:
- CTabs fTabs;
- CLineSpacing fLineSpacing;
-
- short fIndent; //is measured to the left margin (to the right margin if direction is rl), can be -ive(out) or +ive(in)
- short fLeftMarg;
- short fRightMarg;
- };
- //**************************************************************************************************
-
- #endif
-